package edu.usx.server.controller;


import edu.usx.server.pojo.RespBean;
import edu.usx.server.pojo.Sites;
import edu.usx.server.pojo.User;
import edu.usx.server.service.IFavoriteService;
import edu.usx.server.service.IUserService;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.security.Principal;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author Usx
 * @since 2024-07-23
 */
@RestController
@RequestMapping("/favorite")
public class FavoriteController {

    @Resource
    private IFavoriteService favoriteService;
    @ApiOperation("获取收藏列表")
    @GetMapping("/list")
    public RespBean getFavoriteList(Principal principal){

        return favoriteService.getFavoriteList(principal);
    }
    @ApiOperation("新增收藏夹数据")
    @PostMapping("/site/{id}")
    public RespBean addFavoriteSite(@PathVariable Long id,Principal principal) {
        return favoriteService.addSite(id,principal);
    }

    @ApiOperation("删除收藏夹数据")
    @DeleteMapping("/site/{id}")
    public RespBean deleteFavoriteSite (@PathVariable Long id,Principal principal) {
        return favoriteService.deleteFavorite(id,principal);
    }
}
